﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NUnit.Mocks;
using CustomConsole;
using System.Windows;
using WpfConsole.Properties;

namespace WpfConsole.ConsoleTest
{
    [TestFixture]
    public class ConsoleControlTest
    {
        int _fontHeight = Settings.Default.FontHeight;
        int _fontWidth = Settings.Default.FontWidth;

        [Test]
        public void TestCursorRect()
        {
            Point input = new Point(5, 8);

            double expectLeft = 5*_fontWidth;
            double expectTop = 8* _fontHeight;
            double expectRight = expectLeft + _fontWidth;
            double expectBottom = expectTop + _fontHeight;

            DynamicMock mock = CreateMock();

            mock.SetReturnValue("CursorPosition", input);
            ConsoleControl control = new ConsoleControl((IConsoleHost)mock.MockInstance, Settings.Default);
            Rect actual = control.CursorRect();

            Assert.AreEqual(expectLeft, actual.Left, 0.1);
            Assert.AreEqual(expectTop, actual.Top, 0.1);
            Assert.AreEqual(expectRight, actual.Right, 0.1);
            Assert.AreEqual(expectBottom, actual.Bottom, 0.1);
        }

        private static DynamicMock CreateMock()
        {
            DynamicMock mock = new DynamicMock(typeof(IConsoleHost));
            mock.SetReturnValue("StartShell", true);
            return mock;
        }
    }
}
